﻿// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
#pragma once

#include "Common\StepTimer.h"
#include "DeviceResources.h"
#include "Content\SceneRenderer.h"

// Renders Direct2D and 3D content on the screen.
namespace Weathr
{
    class WeathrMain : public IDeviceNotify
    {
    public:
        WeathrMain(const std::shared_ptr<DeviceResources>& deviceResources);
        ~WeathrMain();
        void CreateWindowSizeDependentResources();
        void StartRenderLoop();
        void StopRenderLoop();
        Concurrency::critical_section& GetCriticalSection() { return m_criticalSection; }

        // IDeviceNotify
        virtual void OnDeviceLost();
        virtual void OnDeviceRestored();

        void Update();
        bool Render();
    private:
        // Cached pointer to device resources.
        std::shared_ptr<DeviceResources> m_deviceResources;

        std::unique_ptr<SceneRenderer> m_sceneRenderer;

        Windows::Foundation::IAsyncAction^ m_renderLoopWorker;
        Concurrency::critical_section m_criticalSection;

        // Rendering loop timer.
        DX::StepTimer m_timer;

        // Track current input pointer position.
        float m_pointerLocationX;
    };
}